import java.sql.SQLOutput;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;

public class UTCtransfer {
    public static void main(String[] args) {
        //SimpleDateFormat sdf1 = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss");
        //SimpleDateFormat sdf2 = new SimpleDateFormat("yyyy/MM/dd");
        //String utcDateStr = "2019-08-26T01:49:33.016Z";
        //try {
        //    Date date = sdf1.parse(utcDateStr.substring(0,19));
        //    Calendar cal = Calendar.getInstance();
        //    cal.setTime(date);
        //    cal.add(Calendar.HOUR_OF_DAY,8);
        //    String localDateStr = sdf2.format(cal.getTime());
        //    String str = sdf2.format(localDateStr);
        //    System.out.println(str);
        //} catch (ParseException e) {
        //    e.printStackTrace();
        //}
        SimpleDateFormat sdf1 = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss");
        SimpleDateFormat sdf2 = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        try {
            String utcDateStr = "2019-08-26T02:50:33.023Z";
            Date date = sdf1.parse(utcDateStr.substring(0,19));//拿到Date对象
            Calendar cal = Calendar.getInstance();
            cal.setTime(date);
            cal.add(Calendar.HOUR_OF_DAY,8);   //加8小时
            String localDateStr = sdf2.format(cal.getTime());
            //String str = sdf2.format(localDateStr);//输出格式：2017-01-22 09:28:33
            System.out.println(localDateStr);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
